package cn.tedu.apps_system.base.config;


 import cn.tedu.apps_system.base.interceptors.LoginCheckInterceptor;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginCheckInterceptor())
                .addPathPatterns("/api/v1/users/**", "/api/v1/admin/user/**","/api/v1/order/**",
                        "/api/v1/products/**")  // 保护用户和管理员接口
                .excludePathPatterns("/api/v1/users/public/login", "/api/v1/users/public/reg",
                        "/api/v1/admin/user/login");  // 排除登录和注册
    }
}